package homework1;

public class BubbleSort {

	static int[] str = new int[] { 112, 40, 30, 0, 0,2,3,-1,-3,-123,12321,343 };
	//static int[] str = new int[] { 999,888,777,666,555,444,333,222,111,99,88,77,66,55,44,33 };
	//static int[] str = new int[] { 112, 40, 1, 5, 3 };
	static int tmp = 0;
	
    public static void main(String args[]) {

	display(str);
	
	for (int j = str.length ; j > 0; j--) {
        	for (int i = 0; i < j-1; i++) {
        	    if (str[i] > str[i + 1]) {
        		swap(i);
        	    }
        	    display(str);
        	}
	}

    }
    
    public static void swap(int location){
	//swap with next element in array
	tmp = str[location];
	str[location] = str[location + 1];
	str[location + 1] = tmp;
	
	//resets
	tmp = 0;
    }

    public static void display(int[] s){
	//display array
	for (int current : s) System.out.print(current + ", ");
	System.out.println("");	
    }
}
